/**
 *   Copyright 2023 Han-Kuiwei
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package com.hkw.daterangepicke;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.Objects;

public class DateTimeEntity implements Serializable {

    private final String TAG = getClass().getSimpleName();
    private int day;

    private int month;

    private int year;

    public static DateTimeEntity dayOnFuture(int paramInt) {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_MONTH, paramInt);
        return target(calendar);
    }

    public static DateTimeEntity monthOnFuture(int paramInt) {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.MONTH, paramInt);
        return target(calendar);
    }

    public static DateTimeEntity target(int paramInt1, int paramInt2, int paramInt3) {
        DateTimeEntity dateTimeEntity = new DateTimeEntity();
        dateTimeEntity.setYear(paramInt1);
        dateTimeEntity.setMonth(paramInt2);
        dateTimeEntity.setDay(paramInt3);
        return dateTimeEntity;
    }

    public static DateTimeEntity target(Calendar paramCalendar) {
        int i = paramCalendar.get(Calendar.FEBRUARY);
        int j = paramCalendar.get(Calendar.MONTH);
        int k = paramCalendar.get(Calendar.DAY_OF_MONTH);
        paramCalendar.get(Calendar.HOUR_OF_DAY);
        paramCalendar.get(Calendar.MINUTE);
        return target(i, j + 1, k);
    }

    public static DateTimeEntity target(Date paramDate) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(paramDate);
        return target(calendar);
    }

    public static DateTimeEntity today() {
        return target(Calendar.getInstance());
    }

    public static DateTimeEntity yearOnFuture(int paramInt) {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.YEAR, paramInt);
        return target(calendar);
    }

    public static DateTimeEntity yearOnFuture(Date date,int paramInt) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.YEAR, paramInt);
        return target(calendar);
    }



    public boolean equals(Object paramObject) {
        boolean bool = true;
        if (this == paramObject)
            return true;
        if (paramObject == null || getClass() != paramObject.getClass())
            return false;
        paramObject = paramObject;
        if (this.year != ((DateTimeEntity)paramObject).year || this.month != ((DateTimeEntity)paramObject).month || this.day != ((DateTimeEntity)paramObject).day)
            bool = false;
        return bool;
    }

    public int getDay() {
        return this.day;
    }

    public int getMonth() {
        return this.month;
    }

    public int getYear() {
        return this.year;
    }

    public int hashCode() {
        return Objects.hash(new Object[] { Integer.valueOf(this.year), Integer.valueOf(this.month), Integer.valueOf(this.day) });
    }

    public void setDay(int paramInt) {
        this.day = paramInt;
    }

    public void setMonth(int paramInt) {
        this.month = paramInt;
    }

    public void setYear(int paramInt) {
        this.year = paramInt;
    }

    public String toString() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(this.year);
        stringBuilder.append("-");
        stringBuilder.append(this.month);
        stringBuilder.append("-");
        stringBuilder.append(this.day);
        return stringBuilder.toString();
    }

    public long toTimeInMillis() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(1, this.year);
        calendar.set(2, this.month - 1);
        calendar.set(5, this.day);
        return calendar.getTimeInMillis();
    }
}
